<?php
namespace pinduoduo;

class Oauth
{
    private $sellerCodeUrl = 'https://mms.pinduoduo.com/open.html';

    private $ddkCodeUrl = 'https://jinbao.pinduoduo.com/open.html';

    private $tokenUrl = 'https://open-api.pinduoduo.com/oauth/token';

    public function getCode($type = null, $clientId = '', $redirectUri = '')
    {
        if ($type == 'ddk') {
            $url = $this->ddkCodeUrl . '?response_type=code&client_id=' . $clientId . '&redirect_uri=' . $redirectUri;
        } else {
            $url = $this->sellerCodeUrl . '?response_type=code&client_id=' . $clientId . '&redirect_uri=' . $redirectUri;
        }
        header('Location: ' . $url);
        exit();
    }

    public function getToken($code)
    {
        $url = $this->tokenUrl . '';
        dd($url);
    }
}
